//
//  TPPlayerView.m
//  TPHelper
//
//  Created by xuqiang on 2020/7/28.
//  Copyright © 2020 xuqiang. All rights reserved.
//

#import "TPPlayerView.h"

@implementation TPPlayerView
+ (instancetype)loadFromNib {
    return [[[NSBundle mainBundle] loadNibNamed:@"TPPlayerView" owner:nil options:nil] lastObject];
}

- (IBAction)play:(id)sender {
    UIButton *btn = (UIButton *)sender;
    if (!btn.selected) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(play)]) {
            [self.delegate start];
        }
    }else{
        if (self.delegate && [self.delegate respondsToSelector:@selector(pause)]) {
            [self.delegate pause];
        }
    }
    btn.selected = !btn.selected;
}

- (IBAction)stop:(id)sender {
    self.hidden = YES;
    if (self.delegate && [self.delegate respondsToSelector:@selector(stop)]) {
        [self.delegate stop];
    }
}

- (IBAction)soundAdd:(id)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(soundAdd)]) {
        [self.delegate soundAdd];
    }
}

- (IBAction)soundLess:(id)sender{
    if (self.delegate && [self.delegate respondsToSelector:@selector(soundLess)]) {
        [self.delegate soundLess];
    }
}

@end
